#ifndef STREAMMANAGER_H
#define STREAMMANAGER_H

#include <Phonon/MediaObject>
#include <Phonon/AudioOutput>
#include <Phonon/VolumeSlider>
#include <QNetworkReply>

class StreamManager : public QObject{
	Q_OBJECT;
public:
	StreamManager(QObject* parent);
	QWidget* getVolumeWidget() { return volumeWidget; }
	void updateStreamList();
public slots:
	void play();
	void pause();
	void onBufferStatus(int status);
	void onMetaDataChanged();
	void onStateChanged(Phonon::State newState, Phonon::State oldState);
signals:
	void buffering(int);
	void newSong(QString, QString);
	void gotStream(bool);
private slots:
	void gotStream(QNetworkReply* reply);
private:
	QString stateToString(Phonon::State state);
	Phonon::MediaObject *m_media;
	Phonon::AudioOutput *audioOutput;
	Phonon::VolumeSlider* volumeWidget;
	QHash<QString, QString> streams;
	QStringList currentStreamAddresses;
	int streamIndex;
	QNetworkAccessManager* streamDownloader;
};

#endif 
